package routers

import (
	"demochat/controllers"
	beego "github.com/beego/beego/v2/server/web"
)

func init() {

	//beego.InsertFilter("/*", beego.BeforeExec, func(ctx *context.Context) {
	//	white := map[string]interface{}{
	//		"/login":    "login",
	//		"/sendCode": "sendCode",
	//		"/register": "register",
	//	}
	//	_, ok := white[ctx.Request.URL.Path]
	//	if !ok && !jwt.VerificationToken(ctx) {
	//		ctx.WriteString("请先登录！！！")
	//		return
	//	}
	//})

	//beego 默认路由
	beego.Router("/", &controllers.LoginController{})
	//用户登录页面
	beego.Router("/login", &controllers.LoginController{}, "get:Login")
	//执行登录
	beego.Router("/user/login", &controllers.LoginController{}, "post:UserLogin")
	//验证token
	beego.Router("/vifi", &controllers.LoginController{}, "get:Vifi")
	//获取联系人
	beego.Router("/get/data", &controllers.ChatController{}, "get:GetContacts")
	//Websocket 路由 摸拟聊天
	beego.Router("/chat", &controllers.ChatController{}, "get:Chat")
	//前端验证
	beego.Router("/chat/view", &controllers.ChatController{}, "get:View")
}
